import {Router} from "@angular/router";
import {Injectable} from "@angular/core";
import {StrUtil} from "../../util/StrUtil";
import {NzMessageService} from "ng-zorro-antd/message";
import {BaseHttpService} from "./base.http.service";

@Injectable()
export class CommonService {
  constructor(private router: Router, private msg: NzMessageService, public http: BaseHttpService) {
  }

  intent(url: string) {
    this.router.navigateByUrl(url).then();
  }

  intentOut(url: string): void {
    if (StrUtil.isBlank(url)) {
      return;
    }
    location.href = url;
  }

  public toast(msg: string): void {
    if (StrUtil.isBlank(msg)) {
      return;
    }
    this.msg.create('success', msg);
  }

}
